import { GET_ALL_PERMISSION, GET_ALL_ROLE } from '@/store/role/CONST'
import { State } from '@/store/role/interface'
import { getAllPermission } from '@/api/permission'
import { Commit } from 'vuex'
import { getAllRoles } from '@/api/user'

export default {
  async [GET_ALL_PERMISSION] (context:{ commit:Commit, state:State}) {
    const { data } = await getAllPermission()
    context.commit(GET_ALL_PERMISSION, data)
  },

  async [GET_ALL_ROLE] (context:{commit:Commit, state:State}) {
    const { data: { data: res } } = await getAllRoles()
    context.commit(GET_ALL_ROLE, res)
  }
}
